package crmdna.inventory;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
import com.googlecode.objectify.ObjectifyFilter;

import crmdna.client.Client;
import crmdna.group.Group;
import crmdna.group.Group.GroupProp;
import crmdna.hr.Department;
import crmdna.hr.DepartmentProp;
import crmdna.user.User;
import crmdna.user.User.Action;
import crmdna.user.User.ResourceType;
import crmdna.user.UserCore;

public class IshaInventoryItemTest {
  private final LocalServiceTestHelper datastoreHelper = new LocalServiceTestHelper(
      new LocalDatastoreServiceTestConfig().setApplyAllHighRepJobPolicy());

  private final String client = "isha";
  private final String validUser = "valid@login.com";
  private final String userWithPermission = "withpermission@login.com";
  private GroupProp sgp;
  private GroupProp kl;
  InventoryItemTypeProp book;
  InventoryItemTypeProp rudraksh;

  DepartmentProp nandiFoods;

  @Before
  public void setUp() {
    datastoreHelper.setUp();
    ObjectifyFilter.complete();

    Client.create(client);
    sgp = Group.create(client, "Singapore", User.SUPER_USER);
    assertEquals(1, sgp.groupId);

    kl = Group.create(client, "KL", User.SUPER_USER);
    assertEquals(2, kl.groupId);

    book = InventoryItemType.create(client, "Book", User.SUPER_USER);
    assertEquals(1, book.inventoryItemTypeId);

    rudraksh = InventoryItemType.create(client, "Rudraksh", User.SUPER_USER);
    assertEquals(2, rudraksh.inventoryItemTypeId);

    User.create(client, validUser, sgp.groupId, User.SUPER_USER);
    assertEquals(1, UserCore.get(client, validUser).toProp().userId);

    User.create(client, userWithPermission, sgp.groupId, User.SUPER_USER);
    assertEquals(2, UserCore.get(client, userWithPermission).toProp().userId);
    User.addOrDeletePrivilege(client, userWithPermission, ResourceType.INVENTORY_ITEM, 1,
        Action.WRITE, true, User.SUPER_USER);
    User.addOrDeletePrivilege(client, userWithPermission, ResourceType.INVENTORY_ITEM, 1,
        Action.UPDATE_QUANTITY, true, User.SUPER_USER);

    nandiFoods = Department.create(client, "Nandi Foods", User.SUPER_USER);
  }

  @After
  public void tearDown() {
    ObjectifyFilter.complete();
    datastoreHelper.tearDown();
  }

  @Test
  public void toDo() {
    assertTrue(false);
  }
}
